package com.woniuxy.ticketcinema.controller;

import com.woniuxy.ticketcinema.entity.ResponseResult;
import com.woniuxy.ticketcinema.serviec.CinemaService;
import com.woniuxy.ticketcinema.serviec.SeatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName OrderLinkCinemaController
 * @Description TODO
 * @Author zx
 * @Date 2021-02-27 10:18:36
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("orderLinkCinema")
public class OrderLinkCinemaController {

    @Resource
    private CinemaService cinemaService;

    @Resource
    private SeatService seatService;

    @Transactional
    @GetMapping("orderDto")
    public ResponseResult<?> link(String cinema,String hall,String seat){
        //尝试超时响应
//        try {
//            TimeUnit.SECONDS.sleep(4);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        return new ResponseResult<Double>(200,seatService.findSeatIdByCoord(seat),cinemaService.findIdByName(cinema, hall));
    }
}